package com.tanhua.server.service;

import com.tanhua.server.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 代替springmvc.xml配置
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册了拦截器
        registry.addInterceptor(tokenInterceptor)

                .addPathPatterns("/**")//拦截的路径
                .excludePathPatterns("/user/login", "/user/loginVerification");//放行的路径
    }
}
